﻿using BLL.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FlowerShop.Core.Models;

namespace 花店管理系统
{
    public partial class Tproducts : Form
    {
        public static string Pname = "";
        private ProductService _productService;

        public Tproducts()
        {
            InitializeComponent();
            _productService = new ProductService();
        }

        private void Tproducts_Load(object sender, EventArgs e)
        {
            int productId = Convert.ToInt32(Form1.Productid);
            FlowerShop.Core.Models.Tgood product = _productService.GetProductById(productId);

            if (product != null)
            {
                lblProductid.Text = product.G_id.ToString();
                lblCategoryId.Text = product.L_id;
                lblListPrice.Text = product.G_xiaoshoujia.ToString();
                lblSuppid.Text = product.Y_id;
                lblName.Text = product.G_name;
                lblDescn.Text = product.G_miaosu;
                lblQty.Text = product.G_kuchun.ToString();
                Pname = product.G_name;

                try
                {
                    pictureBox1.Image = Image.FromFile(Application.StartupPath + product.Image);
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                catch
                {
                    pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\" + "暂无图片.png");
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            geren.Quanping qb = new geren.Quanping();
            qb.ShowDialog();
        }
    }
}
